Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
Playwright: "route.continue" occasionally gives error when blocking tracking scripts

I've got a synthetic monitoring test that has been running fine. I've added some code to block third-party ad tracking and analytic scripts to speed up the tests (and not skew analytics), as recommended here: https://scrapingant.com/blog/block-requests-playwright.

At the top of each test I've got this:

await page.route('**/*', filterResources)

And the filterResources method is defined as follows:

const DOMAIN_EXCLUSIONS = [
    'connect.facebook.net',
    'px.ads.linkedin.com',
    [...]
]

module.exports = (route) => {
    let matches = DOMAIN_EXCLUSIONS.filter((domain) => {
        return route.request().url().startsWith('https://' + domain)
    })
    return matches.length ? route.abort() : route.continue()
}

Now occasionally the following error will be thrown, and the test fails:

route.continue: Target page, context or browser has been closed

This maybe happens in one every 6-8 runs.

Is this because the page navigates away while some requests are still outstanding, because Playwright believes the page is already fully loaded? I'm using the proper awaits and the test was working fine before.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'm catching and solving the promise now, and the issue doesn't seem to happen any more:

if (matches.length) {
    return route.abort()
}

return route.continue().catch(() => {})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda